// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#ifndef __H_MK_UI_FONT_RENDER__
#define __H_MK_UI_FONT_RENDER__

#include "mk_ui_define.h"
#include "mk_ft_font.h"

namespace MK3DE
{
    class MK3DE_API CUIFontRender
    {
    public:
        CUIFontRender();
        virtual ~CUIFontRender();

        BOOL Render();
        BOOL UpdateTextDimension();
        void Recalculate();

        void SetFont(int idx);
        void SetFontColor(DWORD color) { _fontColor = color; }
        void SetFontBordParam(FONT_BORDER_TYPE type, DWORD color, DWORD weight)
        {
            _fontBorderType = type;
            _fontBorderColor = color;
            _fontBorderWeight = weight;
        }

        void SetAlignType(UI_ALIGN_TYPE_X x, UI_ALIGN_TYPE_Y y) { _alignTypeX = x; _alignTypeY = y; }

        void SetPosition(float x, float y);
        void SetSize(float sx, float sy);

        void SetText(const wchar_t* text);
        std::wstring& GetText() { return _text; }
        
        void GetStartPos(float& x, float& y) { x = _xText + _pos.x; y = _yText + _pos.y; }
        void GetDimension(float& width, float& height) { width = _width; height = _height; }

    protected:
        std::wstring _text;

        int _fontIdx;
        DWORD _fontColor;
        FONT_BORDER_TYPE _fontBorderType;
        int _fontBorderColor;
        int _fontBorderWeight;
        
        D3DXVECTOR2 _pos;
        D3DXVECTOR2 _size;
        float _xText;
        float _yText;

        UI_ALIGN_TYPE_X _alignTypeX;
        UI_ALIGN_TYPE_Y _alignTypeY;

        float _width;
        float _height;
    };
};

#endif // __H_MK_UI_FONT_RENDER__